package demo01;

public class BigDecimal {
    public static void main(String[] args) {
        double[] arr = {0.1, 0.2, 2.1, 3.2, 5.56, 7.21};
        //平均值  四舍五入
        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        double avg = sum / arr.length;  //获取平均值
        System.out.println("未四舍五入之前的平均值为：" + avg);
        //将结果四舍五入
        double avgRound = Math.round(avg);
        System.out.println("四舍五入之后的平均值为：" + avgRound);
    }
}
